import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:light_image/commom/commom.dart';
import 'package:light_image/pages/login_page.dart';
import 'package:light_image/pages/root_page.dart';
import 'package:light_image/widget/view/loading_view.dart';
import 'package:light_image/widget/view/vercode_timer.dart';
import 'package:mobsms/mobsms.dart';
import 'package:package_info/package_info.dart';
import 'package:shared_preferences/shared_preferences.dart';

import 'guide_page.dart';

class FirstPage extends StatefulWidget {

  _FirstPageState createState() => _FirstPageState();
}

class _FirstPageState extends State<FirstPage>   {

  @override
  void initState() {
    super.initState();

      read().then((onValue){

   pushAndRemoveUntil(GuidePage(), RouterType.material);
//        if(onValue!=null&&onValue .isNotEmpty){
//          Future.delayed(const Duration(milliseconds: 500), () {
//          pushAndRemoveUntil(RootPage(), RouterType.material);
//          });
//        }else{
//          Future.delayed(const Duration(milliseconds: 500), () {
//            pushAndRemoveUntil(LoginPage(), RouterType.material);
//          });

//        }
      });



  }



  @override
  Widget build(BuildContext context) {

    return Scaffold(
//      appBar: AppBar(
//        title:   Text("初始化中...") ,
//        elevation: 0.0,
//        brightness: Brightness.dark,
//        centerTitle: false,
//      ),
//        resizeToAvoidBottomPadding: true, //输入框抵住键盘

    body:Container(child:
      LoadingView(text:"初始化中")
     ,));
  }



  Future<String> read() async {


    SharedPreferences prefs = await SharedPreferences.getInstance();
    var ph = prefs.getString('phone');
    return ph;

  }

}
